//
//  ThemeFontPicker.swift
//  HeadlineNews
//
//  Created by han on 2019/7/25.
//  Copyright © 2019 han. All rights reserved.
//

import UIKit

final class ThemeFontPicker: ThemePicker {
    convenience init(keyPath: String, map: @escaping (Any?) -> UIFont?) {
        self.init(v: { map(ThemeManager.value(for: keyPath)) })
    }
    
    convenience init(fonts: UIFont...) {
        self.init(v: { ThemeManager.element(for: fonts) })
    }
}

extension ThemeFontPicker: ExpressibleByArrayLiteral {
    convenience init(arrayLiteral elements: UIFont...) {
        self.init(v: { ThemeManager.element(for: elements) })
    }
}

extension ThemeFontPicker {
    
    class func pickerWithKeyPath(_ keyPath: String, map: @escaping (Any?) -> UIFont?) -> ThemeFontPicker {
        return ThemeFontPicker(v: { map(ThemeManager.value(for: keyPath)) })
    }
    
    class func pickerWithFonts(_ fonts: [UIFont]) -> ThemeFontPicker {
        return ThemeFontPicker(v: { ThemeManager.element(for: fonts) })
    }
    
}
